#ifndef VMC_LANE_FULL_MATCHING_LOG
#define VMC_LANE_FULL_MATCHING_LOG

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

class Log : public std::ostream, std::stringbuf
{
public:
    static std::string ROOT;
    static Log &Instance()
    {
        static Log singleton;
        return singleton;
    }

    std::string getTime();

    virtual int sync()
    {
        putOutput();
        return 0;
    }

    void putOutput()
    {
        std::string timeStr = getTime();
        log_file_ << "[lanefullmatching][" << timeStr << "]" << str();
        std::cout << "[lanefullmatching][" << timeStr << "]" << str();
        log_file_.flush();
        str("");
    }

private:
    Log();
    ~Log();
    std::ofstream log_file_;
};

#define LOG(msg) Log::Instance() << (msg)

#endif